<template>
	<view class="content">
		<u-navbar :bgColor="vavigateBgcolor" :placeholder="true" :autoBack="true">
			<view slot="center" class="navigate-title">{{ navigateTitle }}</view>
		</u-navbar>

		<view class="info-box">
			<view class="top">
				<view>
					<view class="top-title-blue">合同信息确认</view>
					<view class="top-title-ash">请如实填写相关信息</view>
				</view>
				<image src="../../static/images/stamp.png"></image>
			</view>

			<view class="card">
				<view class="top-box">
					<view class="block"></view>
					<view class="top-title">填写合同信息</view>
				</view>
				<view class="form-box">
					<u--form labelPosition="top" :model="addForm" labelWidth="auto" ref="addForm">
						<view style="height: 24rpx;"></view>
						<u-form-item prop="accreditName">
							<view class="input-label">授权代理人名称</view>
							<u--input v-model="addForm.accreditName" type="text" placeholder="请输入姓名"
								placeholderClass="input-placeholder" :customStyle="inputStyle" border="none"></u--input>
						</u-form-item>
						<u-form-item prop="legalNameaccreditIdCard">
							<view class="input-label">授权代理人身份证号</view>
							<u--input v-model="addForm.accreditIdCard" type="text" placeholder="请输入身份证号"
								placeholderClass="input-placeholder" :customStyle="inputStyle" border="none"></u--input>
						</u-form-item>
						<u-form-item prop="accreditPhone">
							<view class="input-label">手机号</view>
							<u--input v-model="addForm.accreditPhone" type="idcard" placeholder="请输入手机号"
								placeholderClass="input-placeholder" :customStyle="inputStyle" border="none"></u--input>
						</u-form-item>
						<u-form-item prop="companyName">
							<view class="input-label">公司名称</view>
							<u--input v-model="addForm.companyName" type="number" placeholder="请输入手机号公司名称"
								placeholderClass="input-placeholder" :customStyle="inputStyle" border="none"
								:disabled="true" disabledColor="#fff"></u--input>
						</u-form-item>
					</u--form>
				</view>
			</view>

			<view class="btn" @click="toGeneratorContract()">确定</view>

			<uni-popup ref="alertDialog" type="dialog">
				<uni-popup-dialog :type="msgType" cancelText="取消" confirmText="确定" content="请确认信息填写无误"
					@confirm="dialogConfirm" @close="dialogClose"></uni-popup-dialog>
			</uni-popup>
		</view>
	</view>
</template>

<script>
	import {
		generatorContractApi
	} from "@/api/auth.js"
	export default {
		data() {
			return {
				navigateTitle: '合同信息确认',
				vavigateBgcolor: '#dce7ff',
				addForm: {
					accreditName: '',
					accreditIdCard: '',
					accreditPhone: '',
					companyName: '',
					id: '',
				},
				rules: {
					'companyName': {
						type: 'string',
						required: true,
						message: '请填写公司名称',
						trigger: ['blur']
					},
					'accreditName': {
						type: 'string',
						required: true,
						message: '请填写授权代理人名称',
						trigger: ['blur']
					},
					'accreditIdCard': [{
							required: true,
							message: '请输入身份证',
							trigger: ['blur'],
						},
						{
							validator: (rule, value, callback) => {
								return uni.$u.test.idCard(value);
							},
							message: '身份证号码不正确',
							trigger: ['blur'],
						}
					],
					'accreditPhone': [{
							required: true,
							message: '请输入手机号',
							trigger: ['blur'],
						},
						{
							validator: (rule, value, callback) => {
								return uni.$u.test.mobile(value);
							},
							message: '手机号码不正确',
							trigger: ['blur'],
						}
					]
				},
				msgType: 'success',
				companyInfo: {},
			}
		},
		mounted() {
			this.companyInfo = uni.getStorageSync('faceInfo')
			this.addForm = {
				accreditName: this.companyInfo.accreditName,
				accreditIdCard: this.companyInfo.accreditIdCard,
				accreditPhone: this.companyInfo.accreditPhone,
				companyName: this.companyInfo.companyName,
				id: this.companyInfo.id,
			}
		},
		methods: {
			toGeneratorContract() {
				this.$refs.addForm.validate().then(res => {
					this.$refs.alertDialog.open()
				}).catch(errors => {
					uni.$u.toast('请填写正确信息')
				})
			},
			dialogConfirm() {
				uni.setStorageSync('faceRecognitionInfo', this.addForm)
				uni.navigateTo({
					url: '/subpackage/pages/faceRecognition/faceRecognition'
				})
			},
			dialogClose() {
				this.$refs.alertDialog.close()
			},
		},
		computed: {
			inputStyle() {
				const style = {
					'font-size': '20rpx',
					padding: '0 !important',
					'border-bottom': '2rpx solid rgba(227, 227, 227, 1) !important',
				}
				return style
			}
		},
		onReady() {
			this.$refs.addForm.setRules(this.rules)
		},
	}
</script>

<style lang="scss" scoped>
	.content {
		width: 100%;
		margin-left: -30rpx;
		height: 100vh;
		background: linear-gradient(180deg, rgba(220, 231, 255, 1) 0%, rgba(245, 249, 252, 1) 100%) !important;
		padding: 0 30rpx;

		.info-box {
			width: 100%;

			.top {
				display: flex;
				align-items: center;
				justify-content: space-between;

				image {
					width: 230rpx;
					height: 230rpx;
				}

				.top-title-blue {
					color: rgba(65, 136, 239, 1);
					font-size: 42rpx;
					letter-spacing: 6rpx;
				}

				.top-title-ash {
					color: rgba(128, 128, 128, 1);
					font-size: 20rpx;
					letter-spacing: 4rpx;
					margin-top: 14rpx;
				}
			}

			.card {
				width: 100%;
				height: auto;
				border-radius: 24rpx;
				background: rgba(255, 255, 255, 1);
				box-shadow: 0rpx 2rpx 4rpx rgba(0, 0, 0, 0.1);
				padding-bottom: 20rpx;

				.top-box {
					padding: 44rpx 32rpx 0 32rpx;
					display: flex;
					align-items: center;

					.block {
						width: 6rpx;
						height: 30rpx;
						background: rgba(65, 136, 239, 1);
					}

					.top-title {
						font-size: 30rpx;
						font-weight: 700;
						letter-spacing: 2rpx;
						margin-left: 10rpx;
					}
				}

				.form-box {
					padding: 0 48rpx;

					::v-deep .input-placeholder {
						color: #bdbdbd;
						font-size: 20rpx;
					}

					.input-label {
						color: rgba(51, 51, 51, 1);
						font-weight: 700;
						letter-spacing: 2rpx;
						font-size: 28rpx;
						margin: 10rpx 0 24rpx 0;
					}
				}
			}

			.btn {
				width: 640rpx;
				height: 90rpx;
				line-height: 90rpx;
				border-radius: 10rpx;
				background: rgba(65, 136, 239, 1);
				font-size: 30rpx;
				font-weight: 700;
				color: #fff;
				letter-spacing: 8rpx;
				text-align: center;
				position: fixed;
				bottom: 60rpx;
				left: 54rpx;
			}
		}
	}
</style>